package com.guisu.material

import android.content.Context
import android.util.AttributeSet
import android.widget.ScrollView

class MyScrollerView: ScrollView {

    constructor(context: Context): this(context, null)
    constructor(context: Context, attrs: AttributeSet?): this(context, attrs, 0)
    constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int): this(context, attrs, defStyleAttr, 0)
    constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int): super(context, attrs, defStyleAttr, defStyleRes){

    }

    override fun onScrollChanged(l: Int, t: Int, oldl: Int, oldt: Int) {
        super.onScrollChanged(l, t, oldl, oldt)
        listener?.onScroll(l, t, oldl, oldt)
    }

    interface ScrollChangeListener {
        fun onScroll(l: Int, t: Int, oldl: Int, oldt: Int)
    }

    private var listener: ScrollChangeListener? = null
    fun setOnScrollChangeListener(listener: ScrollChangeListener?) {
        this.listener = listener
    }
}